package com.jdls.day15.test;

import java.util.concurrent.Callable;

/**
 * @author 嘉德罗斯
 * @date 2021/8/6
 */
public class Dome4 implements Runnable {
    private int a = 0;
    private Object o = new Object();
    @Override
    public void run() {
        while (true){
        synchronized (this){
                if(a>=100){
                    System.out.println(Thread.currentThread().getName()+"窗口售完");
                    break;
                }else {
                    a++;
                    System.out.println(Thread.currentThread().getName()+"正在卖第"+a+"张票");
                    try {
                        Thread.sleep(10L);
                    } catch (InterruptedException e) {
                        e.printStackTrace();
                    }
                }
            }
        }

    }
}
